import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        // appBar: AppBar(
        //   title: Text('抽屉效果示例'),
        // ),
        drawer: Drawer(
          width: 350,
          child: ListView(
            children: <Widget>[
              UserAccountsDrawerHeader(
                accountName: Text('张三'),
                accountEmail: Text('zhangsan@example.com'),
                currentAccountPicture: CircleAvatar(
                  backgroundImage: NetworkImage('https://example.com/profile.jpg'),
                ),
              ),
              ListTile(
                leading: Icon(Icons.home),
                title: Text('主页'),
                onTap: () {
                  Navigator.of(context).pop(); // 关闭抽屉
                  // 可以在这里处理点击事件，比如导航到主页
                },
              ),
              // ...可以添加更多的ListTile项来实现抽屉的内容
            ],
          ),
        ),
        body: Center(
          child: Builder(
            builder: (context2) {
              return GestureDetector(onTap: (){
                Scaffold.of(context2).openDrawer();

              },child: Container(color: Colors.red,child: Text('这是主体内容区域')));
            }
          ),
        ),
      ),
    );
  }
}